{extend name="layout:base" /}{block name="content"}
 <?php
$global=isSupperManagerForSession();
 ?>
 <style>
.table th{text-align:center;}
</style>
<section class="topBanners">
         <div class="icon"></div>
         <div class="topBannersNav">
         <span data-url="/admin/news/lists" onclick="ContentLoadGo('/admin/news/lists')">新闻管理</span>
         </div>
      </section>
   
      <section style="margin-top:10px;margin-left:auto;margin-right:auto;">
      <select name="ser_key" id="ser_key" class="select" >
       <option value="title" <?php if($request['ser_key']=="content"){echo 'selected';} ?>>新闻标题</option>
      </select>
      
      <input type="text" class="textbox" name="ser_val" id="ser_val" value="<?php echo $request['ser_val']; ?>" placeholder=""/>
     
      <select name="ser_ty" id="ser_ty" class="select">
     <option value="0">--栏目--</option>
      		   <?php
      		    foreach($allType as $key=>$val)
				{
				?>
				<option value="<?php echo $val['id'] ?>" <?php if($val['id']==$request['ser_ty']){echo 'selected';} ?> ><?php echo $val['name']; ?></option>
				<?php
				}
      		    ?>
      </select>
        
         时间：
          <input name="starttime"  id="starttime" class="Wdate textbox" placeholder="开始时间"  onfocus="WdatePicker({lang:'zh-cn'})" value="<?php echo $request['starttime']; ?>" size="12"  type="text" style="padding: 0 5px;font-size: 12px;border: 1px #139667 solid;vertical-align: middle;" >
          -<input name="endtime" id="endtime" class="Wdate textbox" style="padding: 0 5px;font-size: 12px;border: 1px #139667 solid;vertical-align: middle;"  placeholder="结束时间"  onfocus="WdatePicker({lang:'zh-cn'})" value="<?php echo $request['endtime']; ?>" size="12" type="text">
 
      <select id="ser_stats" class="ser_stats select" name="ser_stats">
          <option value="">--状态--</option>
          <option value="0" <?php if($request['ser_stats']=='0'){echo 'selected';} ?> >下架</option>
          <option value="1" <?php if($request['ser_stats']=='1'){echo 'selected';} ?> >上架</option>
      </select>
      
     
      <input type="button" value="搜索" class="group_btn research" id="resource" page="1" />
      	<?php
	    if( ( in_array(30200,$ruleLists) || $global==1) )
	   
		{
    	?>
      <input power="30200" type="button" value="添加" class="group_btn add fr" />
      	<?php
      	}
      	?>
      <br style="clear:both;width:0px;height:0px;">
     </section>
 
       
   
<table class="table" style="margin-top:10px;">

<tr>


<th style="width:50px;">ID</th>
<th style="width:100px;">新闻标题</th>
<th style="width:100px;">类型</th>
<th style="width:100px;">发布时间</th>
<th style="width:100px;">发布人</th>
<th style="width:100px;">状态</th>

<th style="width:100px;">操作</th>
</tr>

<?php 

foreach($lists['data'] as $key=>$val)
{
?>
<tr data-id="<?php echo $val['id']; ?>">
<td style="text-align:left;"><?php echo $val['id']; ?></td>
<td style="text-align:left;"><?php echo $val['title']; ?></td>
<td><?php echo $allType[$val['ty']]['name']; ?></td>
<td><?php echo date("Y-m-d H:i:s",$val['ctime']);?></td>
<td><?php echo $val['UserInfo']['nickname'];?></td>
<td><?php echo showStats($val['stats']);?></td>

<td style="text-align:right;">
<?php
if($val['stats'])
{
?>
<input type="button" power="30300" value="下架" class="link_btn xia"/>	
<?php 
}else
{
?>
<input type="button" power="30300" value="上架" class="link_btn shang"/>
<?php
}
?>
       <?php
	    if( ( in_array(30100,$ruleLists) || $global==1) )
	
		{
    	?>
<input type="button" power="30100" value="详情" class="link_btn info"/>
		<?php
		}
		?>
		<?php
	    if( ( in_array(30300,$ruleLists) || $global==1) )
	
		{
    	?>
<input type="button" power="30300" value="修改" class="link_btn edit"/>
		<?php
		}
		?>
		<?php
	   if( ( in_array(30400,$ruleLists) || $global==1) )
	  
		{
    	?>
<input type="button" power="30400" value="删除" class="link_btn del"/>
		<?php
		}
		?>

</td>
</tr>
      <?php
      }
	  ?>
</table>
{include file="../application/admin/view/layout/page_tpl_new.html" /}
      <script type="text/javascript">
      
      function myResearch(){
		   var url="/admin/news/lists";
		   var ser_key =$("#ser_key").val();
		   var ser_val =$("#ser_val").val();
		   var ser_ty =$("#ser_ty").val();
		   var ser_stats =$("#ser_stats").val();
			  
			 
		   var starttime =$("#starttime").val();
		   var endtime =$("#endtime").val();
           if(starttime!="" && endtime=="")
       		{
          		ErrTiShi("请选择结束日期");return false;
       		}
       		if(starttime=="" && endtime!="")
       		{
          		ErrTiShi("请选择开始日期");return false;
       		}
		   var page=$("#cpage").val();
		   var param={
				   ser_key:ser_key, 
				   ser_val:ser_val, 
				   ser_ty:ser_ty,
				   starttime:starttime, 
				   endtime:endtime, 
				   ser_stats:ser_stats,
				   page:page
		   };
		   ContentLoadGo(url,param);
	   }
     
      
           $(function(){
        	   //设置搜索栏
        	 $(".research").unbind().bind("click",function(){
        		   var page =$(this).attr("page");
        		   $("#cpage").val(page);
        		   myResearch();
        		   
        	   });
        	   
        	   
        	 
      	   $(".shang").unbind().bind("click",function(){
      		   var that =this;
      		   var url="/admin/news/shangData";
      		   var id=$(that).parent().parent().attr('data-id');
      		   var param={
      				   id:id
      		   };
      		   cofirmsss_tishi(1,'您确定要执行该操作吗？',function(id){
      			 
      			   AjaxRequest(url,param,function(data){
          			   if(data.err==0)
          			   {
          				   SuccessTiShi("操作成功");
          				   
          				   $(that).parent().parent().remove();
          				   myResearch();
          			   }
          			   else
          			   {
          				   ErrTiShi(data.msg);
          			   }
          		   });
      			   
      		   });
      	   });
      	
      	   
      	   $(".xia").unbind().bind("click",function(){
      		   var that =this;
      		   var url="/admin/news/xiaData";
      		   var id=$(that).parent().parent().attr('data-id');
      		   var param={
      				   id:id
      		   };
      		   cofirmsss_tishi(1,'您确定要执行该操作吗？',function(id){
      			 
      			   AjaxRequest(url,param,function(data){
          			   if(data.err==0)
          			   {
          				   SuccessTiShi("操作成功");
          				   
          				   $(that).parent().parent().remove();
          				   myResearch();
          			   }
          			   else
          			   {
          				   ErrTiShi(data.msg);
          			   }
          		   });
      			   
      		   });
      	   });
      	
      	   
        	   $(".del").unbind().bind("click",function(){
        		   var that =this;
        		   var url="/admin/news/delData";
        		   var id=$(that).parent().parent().attr('data-id');
        		   var param={
        				   id:id
        		   };
        		   cofirmsss_tishi(1,'您确定要删除吗?',function(id){
        			 
        			   AjaxRequest(url,param,function(data){
            			   if(data.err==0)
            			   {
            				   SuccessTiShi("操作成功");
            				   
            				   $(that).parent().parent().remove();
            				   myResearch();
            			   }
            			   else
            			   {
            				   ErrTiShi("操作失败");
            			   }
            		   });
        			   
        		   });
        	   });
        	
        	   
        	   $(".edit").unbind().bind("click",function(){
        		   var that =this;
        		   var url="/admin/news/editData";
        		   var id=$(that).parent().parent().attr('data-id');
        		   var param={
        				   id:id
        		   };
        		   ContentLoadGo(url,param);
        			
        	   });

        	   $(".info").unbind().bind("click",function(){
        		   var that =this;
        		   var url="/admin/news/infoData";
        		   var id=$(that).parent().parent().attr('data-id');
        		   var param={
        				   id:id
        		   };
        		   ContentLoadGo(url,param);
        			
        	   });
        	   
        	   //导航
     
               $(".topBannerItem").unbind().bind("click",function(){
         		   var attArr = $(this).attr();
             	   goToSelfLink(attArr);
             	   
         			
         	   });
         	  $(".add").unbind().bind("click",function(){
        		   
        		   var that =this;
        		   var url="/admin/news/addData";
        		   var param={};
        		   ContentLoadGo(url,param);
        			 //弹出：确认按钮
        			
        	   });
        	   
  			   //全选
  		  $("#all").unbind().bind("click",function(){
			    	if(this.checked){   
			        	$(".checkBoxInput").attr("checked", true);  
			        	$(".checkBoxInput").prop("checked", true);  
			    	}else{   
						$(".checkBoxInput").attr("checked", false);
						$(".checkBoxInput").prop("checked", false);
			    	}   
			    	var se=getAllSelectItem();
			    	//console.log(se);
			 	}); 
  			   
  			   
  			
           });
           
	  </script>
	  
	  {/block}
   